package com.example.admin.yuejian21.Adapter;

import android.content.Context;
<<<<<<< HEAD
=======
import android.content.Intent;
import android.net.Uri;
>>>>>>> 2e6d2ff2e3331c5e86ecd66212336d2d1a6d7e80
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.VideoView;

<<<<<<< HEAD
import com.example.admin.yuejian21.Bean.Course;
import com.example.admin.yuejian21.R;
import com.example.admin.yuejian21.ViewHolder.CourseViewHolder;
=======

import com.example.admin.yuejian21.Bean.VideoList;
import com.example.admin.yuejian21.R;

import com.example.admin.yuejian21.activity.MasterDetailActivity;
>>>>>>> 2e6d2ff2e3331c5e86ecd66212336d2d1a6d7e80

import java.util.ArrayList;
import java.util.List;

<<<<<<< HEAD
=======
import it.sephiroth.android.library.picasso.Picasso;

import static android.R.id.list;

>>>>>>> 2e6d2ff2e3331c5e86ecd66212336d2d1a6d7e80

/**
 * Created by Admin on 2017/10/19.
 */

public class CourseAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

        private Context mContext;
        private static  int UpUI=1;
        private List mDataList;//数据存储
        private LayoutInflater mLayoutInflater;//准备布局

        public CourseAdapter(Context mContext, List mDataList) {
            this.mContext = mContext;
            this.mDataList = mDataList;
            mLayoutInflater = LayoutInflater.from(mContext);
        }
        @Override
        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View v = mLayoutInflater.from(parent.getContext()).inflate(R.layout.cardview_masterkt, parent, false);
            return new com.example.admin.yuejian21.Adapter.CourseAdapter.VideoViewHolder(v);
        }

        @Override
        public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
            final VideoList.MvideoBean entity = (VideoList.MvideoBean) mDataList.get(position);
            VideoViewHolder videoViewHolder=(VideoViewHolder)holder;
            if (null == entity)
                return;
            MediaController controller=new MediaController(mContext);
            String videoAddress="http://172.24.10.175/workout/Uploads/tvideo/video/ " +entity.getUrl();
            controller.setMediaPlayer(videoViewHolder.videoView);
            videoViewHolder.videoView.setMediaController(controller);
            videoViewHolder.videoView.setVideoPath(Uri.parse(videoAddress).toString());
            videoViewHolder.videoView.start();
            videoViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(mContext,MasterDetailActivity.class);
                    intent.putExtra("dashi_id",entity.getId());
                    mContext.startActivity(intent);
                }
            });
        }

        @Override
        public int getItemCount() {
            return mDataList.size();
        }
        public class VideoViewHolder extends RecyclerView.ViewHolder{
            VideoView videoView;
            public VideoViewHolder(View itemView) {
                super(itemView);
                videoView=(VideoView)itemView.findViewById(R.id.videoView);
            }
        }
    }

<<<<<<< HEAD
    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        CourseViewHolder courseViewHolder =
                (CourseViewHolder) holder;
         Course course = CourseList.get(position);
        ;

if (!(course.getCourse_name().equals("")))       { String Coursename =course.getCourse_name();  courseViewHolder.CoursenameView.setText(Coursename);}
        if (!(course.getCourse_price().equals("")))         {String price=course.getCourse_price();  courseViewHolder.price.setText(price);}
        if (!(course.getIntroduction().equals("")))    {String intro=course.getIntroduction();courseViewHolder.introCourseView.setText(intro);}
        if (!(course.getDegree().equals("")))   {String degree=course.getDegree();        courseViewHolder.levelView.setText(degree);
        }













    }

    @Override
    public int getItemCount() {
        return CourseList.size();
    }
}
=======
>>>>>>> 2e6d2ff2e3331c5e86ecd66212336d2d1a6d7e80
